package com.army.study.utils;

import com.army.study.MainAbility;
import ohos.ace.ability.LocalParticleAbility;

public class JSInterface implements LocalParticleAbility {
    private final MainAbility mainAbility;

    /**
     * 构造方法
     * @param mainAbility
     */
    public JSInterface(final MainAbility mainAbility) {
        this.mainAbility = mainAbility;
    }

    /**
     * JavaScript异步执行调用Java方法。
     * @param callback
     */
    public void getNetWorkIdAsync(final Callback callback) {
        mainAbility.setCallback(callback);
        mainAbility.requestPermissionAndGetNetWorkId();
    }

    /**
     * JavaScript异步执行调用Java方法。
     * @param code
     * @param callback
     */
    public void isAllowGameAsync(final int code, final Callback callback) {
        mainAbility.setCallback(callback);
        mainAbility.isAllowGameAsync(code);
    }

    /**
     * 获取BundleName
     * @return
     */
    public String getBundleName() {
        String bundleName = mainAbility.getBundleName();
        return bundleName;
    }

    /**
     * 获取AbilityName
     * @return
     */
    public String getAbilityName() {
        String abilityName = mainAbility.getClass().getName();
        return abilityName;
    }









}
